package com.cqc.zhbjcqc.activity;

import android.os.Bundle;
import android.support.v4.app.FragmentManager;

import com.cqc.zhbjcqc.R;
import com.cqc.zhbjcqc.fragment.FragHome;
import com.cqc.zhbjcqc.fragment.FragMenuLeft;
import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;
import com.jeremyfeinstein.slidingmenu.lib.app.SlidingFragmentActivity;

public class MainActivity extends SlidingFragmentActivity {

    private FragmentManager fm;
    public SlidingMenu menu;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.frame_main);
        setBehindContentView(R.layout.frame_menu_left);


        menu = getSlidingMenu();
        menu.setMode(SlidingMenu.LEFT);
        menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
        menu.setBehindWidth(300);
        menu.setShadowDrawable(R.drawable.shadow_shape);
        menu.setShadowWidth(3);

        fm = getSupportFragmentManager();

        FragMenuLeft leftFrag = new FragMenuLeft();
        fm.beginTransaction().replace(R.id.frame_menu_left, leftFrag, "FragMenuLeft").commit();

        FragHome homeFrag = new FragHome();
        fm.beginTransaction().replace(R.id.frame_main, homeFrag, "FragHome").commit();

    }

    public FragMenuLeft getFragMenuLeft() {
        return (FragMenuLeft) fm.findFragmentByTag("FragMenuLeft");
    }

    public FragHome getFragHome() {
        return (FragHome) fm.findFragmentByTag("FragHome");
    }
}
